#include "swegl/profiling.h"

#include <stdio.h>
#include <stdlib.h>

namespace Profiling
{

Server Server::Instance;

Server::Server() : m_numZones(0)
{
#if SWEGL_WINDOWS
	QueryPerformanceFrequency((LARGE_INTEGER *) &m_ticksPerSecond);
#elif SWEGL_LINUX
	m_ticksPerSecond = 1000000; // usec
#endif
	m_ticksPerSecondAsDouble = (double) m_ticksPerSecond;
}

void Server::reset()
{
	for (int i = 0; i < Profiling::MAX_PROFILING_ZONES; i++)
	{
		Profiling::Zone *zone = Profiling::Server::Instance.m_zones[i];
		if (! zone) break;
		zone->reset();
	}
}

void Zone::reset()
{
	m_numCalls = 0;
	m_totalTime = 0;
	m_minTime = (uint64) -1;
	m_maxTime = 0;
}

}	

